package com.wxd.woff.utils;

import java.util.List;

/**
 * 字体边界坐标实体
 * 
 * Created with IntelliJ IDEA.
 *
 * @author: wangxindong
 * @date: 2018/9/5-20:52
 */
public class BoundingBox {

    private int lowerLeftX;
    private int lowerLeftY;
    private int upperRightX;
    private int upperRightY;

    public BoundingBox() {
    }

    public BoundingBox(List<Number> numbers) {
        lowerLeftX = numbers.get(0).intValue();
        lowerLeftY = numbers.get(1).intValue();
        upperRightX = numbers.get(2).intValue();
        upperRightY = numbers.get(3).intValue();
    }

    public BoundingBox(int lowerLeftX, int lowerLeftY, int upperRightX, int upperRightY) {
        this.lowerLeftX = lowerLeftX;
        this.lowerLeftY = lowerLeftY;
        this.upperRightX = upperRightX;
        this.upperRightY = upperRightY;
    }

    public boolean contains(int x, int y) {
        return x >= lowerLeftX && x <= upperRightX && y >= lowerLeftY && y <= upperRightY;
    }

    public int getLowerLeftX() {
        return lowerLeftX;
    }

    public void setLowerLeftX(int lowerLeftX) {
        this.lowerLeftX = lowerLeftX;
    }

    public int getLowerLeftY() {
        return lowerLeftY;
    }

    public void setLowerLeftY(int lowerLeftY) {
        this.lowerLeftY = lowerLeftY;
    }

    public int getUpperRightX() {
        return upperRightX;
    }

    public void setUpperRightX(int upperRightX) {
        this.upperRightX = upperRightX;
    }

    public int getUpperRightY() {
        return upperRightY;
    }

    public void setUpperRightY(int upperRightY) {
        this.upperRightY = upperRightY;
    }

    @Override
    public String toString() {
        return "BoundingBox{" +
                "lowerLeftX=" + lowerLeftX +
                ", lowerLeftY=" + lowerLeftY +
                ", upperRightX=" + upperRightX +
                ", upperRightY=" + upperRightY +
                '}';
    }
}
